package gui;

import java.awt.BorderLayout;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JButton;
import java.awt.CardLayout;

public class StartPanel extends JPanel {

	/**
	 * Create the panel.
	 */
	private JButton startNewTournamentBtn;
	private JButton openTournamentbtn;
	private GuiController guiController;
	private Frame frame;
	
	public StartPanel(Frame frame, GuiController guiController) {
		super();
		this.frame = frame;
		this.guiController = guiController;
		initGui();
		initActionListeners();
	}

	private void initGui() {
		startNewTournamentBtn = new JButton("Start nieuw tornooi");
		add(startNewTournamentBtn);
		
		openTournamentbtn = new JButton("Open tornooi");
		add(openTournamentbtn);
	}
	
	private void initActionListeners()
	{
		startNewTournamentBtn.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent arg0) {
				startNewTournament();
			}
		});
	}
	
	private void startNewTournament()
	{
		String tournamentName = JOptionPane.showInputDialog("Voer de naam van het tornooi in: ");
		guiController.getDomainController().makeNewTournament(tournamentName);
		frame.remove(this);
		ConfigurationTournamentPanel configurationTournamentPanel = new ConfigurationTournamentPanel(frame);
		//GamesPanel configurationTournamentPanel = new GamesPanel(frame, true);
		frame.setContentPane(configurationTournamentPanel);
		frame.getContentPane().revalidate();
		frame.getContentPane().repaint();
	}
	
	

}
